package la.bbs558.entity.enums;

import la.bbs558.exception.MsgException;
import la.bbs558.handler.PointsHandler;
import la.bbs558.handler.points.*;
import la.bbs558.util.Objs;
import lombok.Getter;

import java.util.*;

@Getter
public enum PointsOptType {
    SET_AVATAR("设置头像",  SetAvatarHandler.class),
    SET_TEL("手机验证", SetTelHandler.class),
    SET_EMAIL("邮箱验证", SetEmailHandle.class),
    PROMOTION("注册推广", PromHandler.class),
    HIGH_LIGHT("加精", HighLightHandle.class),
    REPLY("发表回复", BbsReplyHandler.class),
    POST("发表帖子", BbsPostHandler.class),
    LIKE("点赞",  LikeHandler.class),
    COLLECT("收藏", CollectHandler.class);

    private final String action;
    private final Class<? extends PointsHandler> handlerClass;

    private final static List<PointsOptType> enums = Arrays.asList(values());

    PointsOptType(String action, Class<? extends PointsHandler> handlerClass) {
        this.action = action;
        this.handlerClass = handlerClass;
    }

    public static PointsOptType getByName(String optType){
        for (PointsOptType value : enums) {
            if(Objs.equal(value.name(),optType)){
                return value;
            }
        }
        throw new MsgException("不存在操作此枚举");
    }
}

